package mobao.baseinfo.user.repository;

import mobao.baseinfo.user.entity.SysUserT;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

public interface SysUserRepository extends JpaRepository<SysUserT,Integer>,JpaSpecificationExecutor<SysUserT> {

    //根据ID修改sysUser信息
    @Transactional
    @Query(value = "update sys_user sm set sm.username=?1,sm.email = ?2,sm.mobile = ?3,status = ?4 where sm.user_id=?5 ", nativeQuery = true)
    @Modifying
    public void updateById(String username,String email,String mobile,Integer status,Integer userId);
    //修改Storm的state的状态
    @Transactional
    @Query(value = "update sys_user sm set sm.status=?2 where sm.user_id=?1 ", nativeQuery = true)
    @Modifying
    public void updateStatus(Integer userId,Integer status);
    //修改Storm的密码
    @Transactional
    @Query(value = "update sys_user sm set sm.password=?2,sm.salt=?3 where sm.user_id=?1 ", nativeQuery = true)
    @Modifying
    public void updatePwd(Integer userId,String password,String salt);
}
